import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
]

const router = new VueRouter({
  routes
})

// 登陆拦截
router.beforeEach(function(to, from, next) {
  let token = localStorage.getItem("czToken")
  if (!token) {
      if (to.path !== '/login') {
          return next('/login')
      }
  }
  next()
})
export default router
